<template>
    <div class="multchart">
        <!-- 多图形 -->
        <div
            ref="collapseItem"
            :id="item.id"
            v-loading="item.loading"
            v-for="item in mulChart"
            :key="item.id"
            element-loading-background="rgba(0, 0, 0, 0.6)"
            class="chart_item"
            :style="`width:${chartstyle[0]}; height:${chartstyle[1]};`"
        >
            <hight-charts :box="box" :options="item.options" :ref="item.id" :id="item.id" :type="item.type || 'eige'" :sensorInfo="sensorInfo" @getFilter="getFilter" />
        </div>
    </div>
</template>

<script>
import hightCharts from './hightCharts'

export default {
    data() {
        return {
            data() {
                return {
                    isLoading: false,
                    box: 'mult',
                    options: null,
                }
            },
        }
    },
    props: {
        mulChart: {
            type: Array,
            default: [],
        },
        sensorInfo: {
            type: Object,
            default: null,
        },
    },
    computed: {
        chartstyle() {
            let len = this.mulChart.length
            if (len <= 3 && len > 0) return ['100%', `${100 / len}%`]
            else if (len > 3) return ['100%', `${100 / 3}%`]
        },
    },
    components: {
        hightCharts,
    },
    methods: {
        getFilter(e) {

            e.options = this.options
            this.$emit('getFilter', e)
        },
        draw(options, ref) {
            this.options = options
            this.$nextTick(() => {
                this.$refs[ref][0].updateChart(options)

                this.mulChart.forEach((e) => {
                    if (e.id == ref) e.loading = false
                })
            })
        },
    },
    created() {},
}
</script>

<style lang="less" scoped>
.multchart {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    .chart_item {
        float: left;
    }
}
</style>
